﻿using System;
using System.Net.Mail;
using Common.Logging;
using System.Reflection;

namespace DotNetNexusSpam.SpamFilter
{
    /// <summary>
    /// Every filter needs to inherit from the base filter class in order to get fired by the spam engine.
    /// Once the filter has been fired, it must define wheter the email is considered as spam or
    /// as spam suspicious. It must also define what action needs to be taken (for example: delete email).
    /// </summary>
    abstract class FilterBase
    {
        public static string NAME = "FilterBase";

        protected ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
        public ILog Log
        {
            get { return _log; }
        }

        private string _name;
        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        private bool _isSpam;
        public bool IsSpam {
            get { return _isSpam;  }
            set { _isSpam = value;  }
        }

        private FilterAction _actionToTake;
        public FilterAction ActionToTake
        {
            get { return _actionToTake; }
            set { _actionToTake = value; }
        }

        private CDOMessageWrapper _email;
        public CDOMessageWrapper Email
        {
            get { return _email; }
            set { _email = value; }
        }

        private string _startupPath;
        public string StartupPath
        {
            get { return _startupPath; }
            set { _startupPath = value; }
        }

        public FilterBase(CDOMessageWrapper email, string startupPath)
        {
            _email = email;
            _startupPath = startupPath;
            LoadConfiguration();
        }

        public abstract void Fire();
        public abstract void LoadConfiguration();
    }
}
